package com.eairlv.route.server.controller;

import com.eairlv.route.server.entity.Result;
import com.eairlv.route.server.entity.form.RouteForm;
import com.eairlv.route.server.entity.vo.AuthenticationProperties;
import com.eairlv.route.server.service.RouteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author eairlv
 * @description
 * @date 15:58 2019/12/11
 */
@Slf4j
@Api(tags = "路由接口")
@RestController
@RequestMapping("/route/server")
public class RouteController {

    @Autowired
    RouteService routeService;

    @GetMapping("/{key}")
    @ApiOperation("获取路由KEY的认证信息")
    public Result<AuthenticationProperties> key(@PathVariable String key, Integer type) {
        return routeService.key(key, type);
    }

    @GetMapping("/session/{session}")
    @ApiOperation("获取路由KEY的认证信息")
    public Result<AuthenticationProperties> session(@PathVariable String session) {
        return routeService.session(session);
    }

    @PostMapping
    @ApiOperation("新增或覆盖路由KEY的认证信息")
    public Result route(@RequestBody RouteForm routeForm) {
        return routeService.route(routeForm);
    }

}
